home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F46904_xsPow.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-07-12  |  1.6 KB  |  56 lines

  1. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  2.     <xsl:output method="text"/>
  3.  
  4.     <xsl:template match="/">
  5.       <xsl:call-template name="pow">
  6.         <xsl:with-param name="base" select="/power/base"/>
  7.         <xsl:with-param name="pow"  select="/power/pow"/>
  8.       </xsl:call-template>
  9.     </xsl:template>
  10.  
  11.     <xsl:template name="pow">
  12.       <xsl:param name="base" select="1"/>
  13.       <xsl:param name="pow"  select="0"/>
  14.       <xsl:param name="tmpResult" select="1"/>
  15.  
  16.       <xsl:variable name="result">
  17.         <xsl:choose>
  18.           <xsl:when test="$pow >= 0">
  19.             <xsl:value-of select="$tmpResult * $base"/>
  20.           </xsl:when>
  21.           <xsl:otherwise>
  22.             <xsl:value-of select="$tmpResult div $base"/>
  23.           </xsl:otherwise>
  24.         </xsl:choose>
  25.       </xsl:variable>
  26.  
  27.       <xsl:variable name="incr">
  28.         <xsl:choose>
  29.           <xsl:when test="$pow >= 0">
  30.             <xsl:value-of select="- 1"/>
  31.           </xsl:when>
  32.           <xsl:otherwise>
  33.             <xsl:value-of select="1"/>
  34.           </xsl:otherwise>
  35.         </xsl:choose>
  36.       </xsl:variable>
  37.  
  38.  
  39.       <xsl:choose>
  40.         <xsl:when test="$pow = 0">
  41.           <xsl:value-of select="$tmpResult"/>
  42.         </xsl:when>
  43.         <xsl:otherwise>
  44.           <xsl:call-template name="pow">
  45.             <xsl:with-param name="base" select="$base"/>
  46.             <xsl:with-param name="pow" select="$pow + $incr"/>
  47.             <xsl:with-param name="tmpResult"  select="$result"/>
  48.           </xsl:call-template>
  49.         </xsl:otherwise>
  50.       </xsl:choose>
  51.     </xsl:template>
  52. </xsl:stylesheet>
  53.  
  54.  
  55.  
  56.